import http from './http';

//用户登陆方法
const userLogin = (username: any, password: any) => {
	return http.request({
		url: 'index/login',
		method: 'post',
		data: {
			username: username,
			password: password,
		},
	});
};

//获取左侧菜单
const querymenus = () => {
	return http.request({
		url: 'homep/menu',
		method: 'get',
	});
};

//获取商品信息的大类名称
const query_goodsinfo = (sign: Number) => {
	return http.request({
		url: 'GoodsInfo/get_GoodsInfo',
		method: 'post',
		data: {
			sign: sign,
		},
	});
};

//获取商品信息明细表格
const query_goodsinfotable = (table: string, current_page: Number, page_size: Number) => {
	return http.request({
		url: 'GoodsInfo/get_GoodsInfoTable',
		method: 'post',
		data: {
			table: table,
			current_page: current_page,
			page_size: page_size,
		},
	});
};

//新增商品信息
const inssert_goodsinfotable = (table: string, data: any) => {
	return http.request({
		url: 'GoodsInfo/insert_GoodsInfoTable',
		method: 'post',
		data: {
			table: table,
			data: data,
		},
	});
};

//更新商品信息
const update_goodsinfotable = (id: any, table: string, data: any) => {
	return http.request({
		url: 'GoodsInfo/update_GoodsInfoTable',
		method: 'post',
		data: {
			id: id,
			table: table,
			data: data,
		},
	});
};

//删除商品信息
const delete_goodsinfotable = (id: number, table: string) => {
	return http.request({
		url: 'GoodsInfo/delete_GoodsInfoTable',
		method: 'post',
		data: {
			id: id,
			table: table,
		},
	});
};

//获取角色信息
const get_roleinfo = (current_page: Number, page_size: Number) => {
	return http.request({
		url: 'Role/Get_RoleInfo',
		method: 'post',
		data: {
			current_page: current_page,
			page_size: page_size,
		},
	});
};

//新增角色信息
const insert_roleinfo = (data: any) => {
	return http.request({
		url: 'Role/Insert_RoleInfo',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//修改角色信息
const update_roleinfo = (id: number, data: any) => {
	return http.request({
		url: 'Role/Update_RoleInfo',
		method: 'post',
		data: {
			id: id,
			data: data,
		},
	});
};

//删除角色信息
const delete_roleinfo = (id: number) => {
	return http.request({
		url: 'Role/Delete_RoleInfo',
		method: 'post',
		data: {
			id: id,
		},
	});
};

//获取所有权限和角色对应的权限
const get_rightinfo = (id: number) => {
	return http.request({
		url: 'Role/Get_RightInfo',
		method: 'post',
		data: {
			role_id: id,
		},
	});
};

//分配权限
const set_right = (id: number, right: any) => {
	return http.request({
		url: 'Role/Update_SetRight',
		method: 'post',
		data: {
			role_id: id,
			right: right,
		},
	});
};

//查询所有非根用户
const get_userinfo = (current_page: Number, page_size: Number) => {
	return http.request({
		url: 'User/Get_UserInfo',
		method: 'post',
		data: {
			current_page: current_page,
			page_size: page_size,
		},
	});
};

//新增用户和分配角色
const inter_userinfo = (data: any) => {
	return http.request({
		url: 'User/Insert_UserInfo',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//修改用户
const update_userinfo = (data: any, id: number) => {
	return http.request({
		url: 'User/Update_UserInfo',
		method: 'post',
		data: {
			data: data,
			id: id,
		},
	});
};

//删除用户
const delete_userInfo = (id: number) => {
	return http.request({
		url: 'User/Delete_UserInfo',
		method: 'post',
		data: {
			id: id,
		},
	});
};

//获取宝石信息的大类名称
const get_stoneinfo = () => {
	return http.request({
		url: 'StoneInfo/Get_StoneInfo',
		method: 'get',
	});
};

//获取点击宝石表格具体的信息
const get_stoneinfotable = (table: string, current_page: Number, page_size: Number) => {
	return http.request({
		url: 'StoneInfo/Get_StoneInfoTable',
		method: 'post',
		data: {
			table: table,
			current_page: current_page,
			page_size: page_size,
		},
	});
};

//新增宝石信息

const inssert_stoneinfotable = (table: string, data: any) => {
	return http.request({
		url: 'StoneInfo/Insert_StoneInfo',
		method: 'post',
		data: {
			table: table,
			data: data,
		},
	});
};

//修改宝石信息
const update_stoneinfotable = (id: any, table: string, data: any) => {
	return http.request({
		url: 'StoneInfo/Update_StoneInfo',
		method: 'post',
		data: {
			id: id,
			table: table,
			data: data,
		},
	});
};

//删除商品信息
const delete_stoneinfotable = (id: number, table: string) => {
	return http.request({
		url: 'StoneInfo/Delete_StoneInfo',
		method: 'post',
		data: {
			id: id,
			table: table,
		},
	});
};

//返回所有供应商
const get_supplierinfo = (current_page: number, page_size: number) => {
	return http.request({
		url: 'Supplier/Get_SupplierInfo',
		method: 'post',
		data: {
			current_page: current_page,
			page_size: page_size,
		},
	});
};

//新增供应商
const insert_supplierinfo = (data: any) => {
	return http.request({
		url: 'Supplier/Insert_SupplierInfo',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//更新供应商
const update_supplierinfo = (id: number, data: any) => {
	return http.request({
		url: 'Supplier/Update_SupplierInfo',
		method: 'post',
		data: {
			data: data,
			id: id,
		},
	});
};

//删除供应商
const delete_supplierinfo = (id: number) => {
	return http.request({
		url: 'Supplier/Delete_SupplierInfo',
		method: 'post',
		data: {
			id: id,
		},
	});
};

//获取分店
const get_branchinfo = (current_page: number, page_size: number) => {
	return http.request({
		url: 'Branch/Get_BranchInfo',
		method: 'post',
		data: {
			current_page: current_page,
			page_size: page_size,
		},
	});
};

//新增分店
const insert_branchinfo = (data: any) => {
	return http.request({
		url: 'Branch/Insert_BranchInfo',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//修改分店
const update_branchinfo = (id: number, data: any) => {
	return http.request({
		url: 'Branch/Update_BranchInfo',
		method: 'post',
		data: {
			data: data,
			id: id,
		},
	});
};

//删除分店
const delete_branchinfo = (id: number) => {
	return http.request({
		url: 'Branch/Delete_BranchInfo',
		method: 'post',
		data: {
			id: id,
		},
	});
};

//获取客户
const get_customerinfo = (current_page: number, page_size: number) => {
	return http.request({
		url: 'Customer/Get_CustomerInfo',
		method: 'post',
		data: {
			current_page: current_page,
			page_size: page_size,
		},
	});
};

//新增客户
const insert_customerinfo = (data: any) => {
	return http.request({
		url: 'Customer/Insert_CustomerInfo',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//修改客户
const update_customerinfo = (id: number, data: any) => {
	return http.request({
		url: 'Customer/Update_CustomerInfo',
		method: 'post',
		data: {
			data: data,
			id: id,
		},
	});
};

//删除客户
const delete_customerinfo = (id: number) => {
	return http.request({
		url: 'Customer/Delete_CustomerInfo',
		method: 'post',
		data: {
			id: id,
		},
	});
};

//查询进货单及明细
const get_purchasebillinfo = (current_page: number, page_size: number, begindate?: string, enddate?: string, billnumber?: string, state?: string, branchId?: number) => {
	return http.request({
		url: 'PurchaseBill/Get_PurchaseBillInfo',
		method: 'post',
		data: {
			current_page: current_page,
			page_size: page_size,
			begindate: begindate,
			enddate: enddate,
			billnumber: billnumber,
			state: state,
			branchId: branchId,
		},
	});
};

//新增进货单
const Add_PurchaseBill = (purchaseBill: any, PurchaseDetailBill: any) => {
	return http.request({
		url: 'PurchaseBill/Add_PurchaseBill',
		method: 'post',
		data: {
			purchaseBill: purchaseBill,
			PurchaseDetailBill: PurchaseDetailBill,
		},
	});
};

//查询所有基础信息
const get_basicsinfo = () => {
	return http.request({
		url: 'PurchaseBill/Get_BasicsInfo',
		method: 'post',
	});
};

//查询是否已有基础资料
const checkImportData = (data: any) => {
	return http.request({
		url: 'PurchaseBill/checkImportData',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//新增基础资料
const Add_basicsinfo = (data: any) => {
	return http.request({
		url: 'PurchaseBill/addBaseData',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//找查相应的基础资料id,并返回
const Get_IdByFieldAndValue = (data: any) => {
	return http.request({
		url: 'PurchaseBill/getIdByFieldAndValue',
		method: 'post',
		data: {
			data: data,
		},
	});
};

//确认进货单
const Confirm_PurchaseBill = (PurchaseBill_id: any) => {
	return http.request({
		url: 'PurchaseBill/confirmBill',
		method: 'post',
		data: {
			PurchaseBill_id: PurchaseBill_id,
		},
	});
};

//作废进货单
const Cancel_PurchaseBill = (PurchaseBill_id: any) => {
	return http.request({
		url: 'PurchaseBill/invalidBill',
		method: 'post',
		data: {
			PurchaseBill_id: PurchaseBill_id,
		},
	});
};

//删除进货单
const delete_purchasebillinfo = (PurchaseBill_id: any) => {
	return http.request({
		url: 'PurchaseBill/deletePurchaseBill',
		method: 'post',
		data: {
			PurchaseBill_id: PurchaseBill_id,
		},
	});
};

//修改进货单主表
const update_purchasebillinfo = (PurchaseBill_id: any, data: any) => {
	return http.request({
		url: 'PurchaseBill/updatePurchaseBill',
		method: 'post',
		data: {
			PurchaseBill_id: PurchaseBill_id,
			data: data,
		},
	});
};

//修改进货单明细表
const update_PurchaseDetailinfo = (PurchaseDetailBill_id: any, data: any) => {
	return http.request({
		url: 'PurchaseBill/updatePurchaseDetailBill',
		method: 'post',
		data: {
			PurchaseDetailBill_id: PurchaseDetailBill_id,
			data: data,
		},
	});
};
//删除进货单明细表
const delete_PurchaseDetailinfo = (PurchaseDetailBill_id: any) => {
	return http.request({
		url: 'PurchaseBill/deletePurchaseDetailBill',
		method: 'post',
		data: {
			PurchaseDetailBill_id: PurchaseDetailBill_id,
		},
	});
};

export { userLogin, querymenus, query_goodsinfo, query_goodsinfotable, inssert_goodsinfotable, update_goodsinfotable, delete_goodsinfotable, get_roleinfo, insert_roleinfo, update_roleinfo, delete_roleinfo, get_rightinfo, set_right, get_userinfo, inter_userinfo, update_userinfo, delete_userInfo, get_stoneinfo, get_stoneinfotable, inssert_stoneinfotable, update_stoneinfotable, delete_stoneinfotable, get_supplierinfo, insert_supplierinfo, update_supplierinfo, delete_supplierinfo, get_branchinfo, insert_branchinfo, update_branchinfo, delete_branchinfo, get_customerinfo, insert_customerinfo, update_customerinfo, delete_customerinfo, get_purchasebillinfo, get_basicsinfo, Add_PurchaseBill, checkImportData, Add_basicsinfo, Get_IdByFieldAndValue, Confirm_PurchaseBill, Cancel_PurchaseBill, delete_purchasebillinfo, update_purchasebillinfo, update_PurchaseDetailinfo, delete_PurchaseDetailinfo };
